package com.jms.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;

/**
 * create by yongli on 2021-06-05 15:06
 */
@Configuration
public class SpringUtil implements ApplicationContextAware {

    private static ApplicationContext app;

    public static <T> T getBean(Class<T> tClass) {
        return app.getBean(tClass);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        app = applicationContext;
    }
}
